function drawPreconditionerRelatedFigures()
% Preconditioners in 2D and 3D
drawPreconditioner;

cgtol=1e-12;
precision='double';

%Histograms of the singular values of Hpp and HMpp 

n=22;
trivialH=calculatePreconditioner2D(n,0,precision);
nonTrivialH=calculatePreconditioner2D(n,1,precision);
trivialSVD=calculateSVD2D(trivialH,n,precision);
nonTrivialSVD=calculateSVD2D(nonTrivialH,n,precision);

[n1,~] = hist(trivialSVD,n^2);
name='2Dspectrum_no_precond';
figure('name',name);
bar(n1'/sum(n1));
set(gca,'XTick',[]);
save_pic(name);
[n2,~] = hist(nonTrivialSVD,n^2);
name='2Dspectrum_with_precond';
figure('name',name);
bar(n2/sum(n2));
set(gca,'XTick',[]);
save_pic(name);

trivialH=calculatePreconditioner3D(n,0,precision);
nonTrivialH=calculatePreconditioner3D(n,1,precision);
trivialSVD=calculateSVD3D(trivialH,n,precision);
nonTrivialSVD=calculateSVD3D(nonTrivialH,n,precision);

[n1,~] = hist(trivialSVD,n^3);
name='3Dspectrum_no_precond';
figure('name',name);
bar(n1'/sum(n1));
set(gca,'XTick',[]);
save_pic(name);
[n2,~] = hist(nonTrivialSVD,n^3);
name='3Dspectrum_with_precond';
figure('name',name);
bar(n2/sum(n2));
set(gca,'XTick',[]);
save_pic(name);

%Condition number of Hpp and HMpp computed directly using SVD vs
%condition number estimated using iterative norm estimation 

%2D
testPreconditionerParams2D(1)
%3D
testPreconditionerParams3D(1)

%condition number estimated using iterative norm estimation
%and number of CG iteration to converge for large n

%2D
testPreconditionerParams2D(0)
%3D
testPreconditionerParams3D(0)

end
